package com.xxl.spring.bean;

import com.xxl.spring.homework.Engine;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Data
@AllArgsConstructor
@Builder
@Component
public class Car {
    private String plateNumber;
    private String brand;
    private double price;
    @Resource(name = "v8")
    private Engine engine;

    public Car() {
        System.out.println("车车，好快的车车");
    }

    public void run(){
        if (engine!=null){
            engine.run();
        }else {
            System.out.println("没有引擎！");
        }
    }

    public void init(){
        System.out.println("init");
    }
    public void destroy(){
        System.out.println("destroy");
    }
}
